package org.nowcoder.huawei.c100;

import java.io.BufferedReader;
import java.io.InputStreamReader;


/**
 * 5：螺旋数字矩阵
 */

public class HC005 {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String[] vars = br.readLine().split(" ");
            int n = Integer.parseInt(vars[0]); //个数
            int row = Integer.parseInt(vars[1]); //行数
            int clo = (int) Math.ceil((double) n / row); //列数
            solve(row, clo, n);
        } catch (Exception ignore) {
        }
    }

    public static void solve(int row, int clo, int n) {
        int[][] martix = new int[row][clo];
        int num = 1;
        int top = 0, down = row - 1;
        int left = 0, right = clo - 1;
        while (num <= n) {
            for (int i = left; i <= right; i++) {
                if (num <= n) {
                    martix[top][i] = num++;
                } else {
                    break;
                }
            }
            top++;

            for (int i = top; i <= down; i++) {
                if (num <= n) {
                    martix[i][right] = num++;
                } else {
                    break;
                }
            }
            right--;

            for (int i = right; i >= left; i--) {
                if (num <= n) {
                    martix[down][i] = num++;
                } else {
                    break;
                }
            }
            down--;

            for (int i = down; i >= top; i--) {
               if (num <= n){
                   martix[i][left] = num++;
               }else {
                   break;
               }
            }
            left++;
        }

        for (int i = 0; i < row; i++) {
            for (int j = 0; j < clo; j++) {
                if (martix[i][j] == 0) {
                    System.out.print("* ");
                } else {
                    System.out.print(martix[i][j] + " ");
                }
            }
            System.out.println();
        }
    }
}
